package cloud.demarcia.rabbitregister.conf;

import cloud.demarcia.rabbitregister.constant.RsaKey;
import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.crypto.asymmetric.RSA;
import cn.hutool.jwt.signers.JWTSigner;
import cn.hutool.jwt.signers.JWTSignerUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.security.Key;
import java.security.PrivateKey;
import java.security.PublicKey;

/**
 * @author Bojun Wen, wen_bj@outlook.com
 * @date 2022.02.19
 */
@Configuration
public class TokenConfig {

    //token 签名器
    public @Bean JWTSigner getJwtSigner(){
        RSA rsa=new RSA(RsaKey.getPrivateKeyStr(),RsaKey.getPublicKeyStr());
        PrivateKey privateKey = rsa.getPrivateKey();
        PublicKey publicKey = rsa.getPublicKey();
        return JWTSignerUtil.rs256(privateKey);
    }
}
